package com.atguigu.sprincloud.controller;

import com.atguigu.sprincloud.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @ClassName:
 * @Description:
 * @version: v1.1.0
 * @author: shuaiqin
 * @date: 2021/8/31-17:29
 * <p>
 * Modification History:
 * Date         Author          Version            Description
 * ------------------------------------------------------------
 * 2021/8/31          shuaiqin          v1.1.0               修改原因
 */
@RestController
@Slf4j
public class PaymentController {
    @Resource
    private PaymentService paymentService;
    @Value("${server.port}")
    private String serverPort;
    @GetMapping("/payment/hystrix/ok/{id}")
    public String paymentOk(@PathVariable("id") Integer id){
        String result = paymentService.paymentOk(id);
        log.info("**************"+result);
        return result;
    }
    @GetMapping("/payment/hystrix/nok/{id}")
    public String paymentnOk(@PathVariable("id") Integer id){
        String result = paymentService.paymentTimeEror(id);
        log.info("**************"+result);
        return result;
    }
    @GetMapping("/payment/circuit/{id}")
    public String paymentCircuit(@PathVariable("id") Integer id){
        String result = paymentService.paymentTimeCircuitBreaker(id);
        log.info("**************"+result);
        return result;
    }
}
